//
//  CheckpointCaptureView.m
//  iphone-client
//
//  Created by Stefan Ivanov on 12/19/11.
//  Copyright (c) 2011 Robolo. All rights reserved.
//

#import "CheckpointCaptureView.h"

@implementation CheckpointCaptureView

@synthesize catchButton;
@synthesize catchLabel;
@synthesize activityView;
@synthesize isCapturing;

- (id)initWithFrame:(CGRect)frame sender:(id)sender
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        //load the background color from the image with the pattern
        self.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"barbackground.png"]]autorelease];
        
        //set isCapturing to no initially
        isCapturing = NO;
        
        //create a button and set its properties
        catchButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        //
        [catchButton addTarget:sender action:@selector(collectOrCancel:) forControlEvents:UIControlEventTouchUpInside];
        //set its frame
        [catchButton setFrame:CGRectMake(10, 5, 80, 40)];
        //set up the text font and color and contents
        [catchButton setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
        catchButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0];
        [catchButton setTitle:@"Collect" forState:UIControlStateNormal];
        [self addSubview:catchButton];
        
        //create a label
        catchLabel = [[[UILabel alloc] initWithFrame:CGRectMake(105, 5, 160, 40)]autorelease];
        //set up the text font, color and contents and the bacground of the label to be transparent
        catchLabel.textColor = [UIColor purpleColor];
        [catchLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20.0]];
        [catchLabel setText:@"Points available"];
        [catchLabel setBackgroundColor:[UIColor clearColor]];
        //add to the view
        [self addSubview:catchLabel];
        
        activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
        activityView.frame = CGRectMake(270, 5, 40, 40);
        [self addSubview: activityView];
        
        //make all 75% transparent for some map visibility
        self.alpha = 0.0;
        
    }
    return self;
}

-(void) dealloc
{
    [catchButton release];
    [catchLabel release];
    [activityView release];
    [super dealloc];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
